home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / include / plcore.h < prev    next >
C/C++ Source or Header  |  1994-08-26  |  13KB  |  738 lines

  1. /* $Id: plcore.h,v 1.24 1994/08/26 19:17:44 mjl Exp $
  2.  * $Log: plcore.h,v $
  3.  * Revision 1.24  1994/08/26  19:17:44  mjl
  4.  * Entries for conex device added; contributed by Mark Olesen.
  5.  *
  6.  * Revision 1.23  1994/07/25  06:05:35  mjl
  7.  * Added dispatch table entry for new lj_hpgl driver.
  8.  *
  9.  * Revision 1.22  1994/07/19  22:36:10  mjl
  10.  * Included plDevs.h.  Driver enabling macro renamed to PLD_<driver>, where
  11.  * <driver> is xwin, ps, etc.  See plDevs.h for more detail.
  12.  *
  13.  * Revision 1.21  1994/06/30  18:29:21  mjl
  14.  * Include-guards included, and the PLStream pointer made global.  The latter
  15.  * will make access to PLplot state information much easier.
  16. */
  17.  
  18. /*    plcore.h
  19.  
  20.     Contains declarations for core plplot data structures.  This file
  21.     should be included only by plcore.c.
  22. */
  23.  
  24. #ifndef __PLCORE_H__
  25. #define __PLCORE_H__
  26.  
  27. #include "plplotP.h"
  28. #include "drivers.h"
  29. #include "plDevs.h"
  30.  
  31. /* Static function prototypes */
  32.  
  33. static void    grline        (short *, short *, PLINT);
  34. static void    grpolyline    (short *, short *, PLINT);
  35. static void    grfill        (short *, short *, PLINT);
  36. static void    difilt        (PLINT *, PLINT *, PLINT,
  37.                  PLINT *, PLINT *, PLINT *, PLINT *);
  38. static void    plGetDev    (void);
  39. static void    pldi_ini    (void);
  40. static void    calc_diplt    (void);
  41. static void    calc_didev    (void);
  42. static void    calc_diori    (void);
  43. static void    calc_dimap    (void);
  44.  
  45. /* Static variables */
  46.  
  47. static PLINT xscl[PL_MAXPOLY], yscl[PL_MAXPOLY];
  48.  
  49. static PLINT font, initfont, fontset;    /* font control parameters */
  50. static PLINT offset;            /* offset for dispatch calls */
  51.  
  52. /*----------------------------------------------------------------------*\
  53. * Allocate a PLStream data structure (defined in plstream.h).
  54. *
  55. * This struct contains a copy of every variable that is stream dependent.
  56. * Only the first [index=0] stream is statically allocated; the rest
  57. * are dynamically allocated when you switch streams (yes, it is legal
  58. * to only initialize the first element of the array of pointers).
  59. \*----------------------------------------------------------------------*/
  60.  
  61. static PLStream pls0;            /* preallocated stream */
  62. static PLINT ipls;            /* current stream number */
  63.  
  64. static PLStream *pls[PL_NSTREAMS] = {&pls0};    /* Array of stream pointers */
  65.  
  66. /* Current stream pointer.  Global, for easier access to state info */
  67.  
  68. PLStream *plsc = &pls0;
  69.  
  70. /*----------------------------------------------------------------------*\
  71. * Define structure containing pointers to device dependent functions.
  72. *
  73. * pl_MenuStr    Pointer to string that is printed in device menu. 
  74. *
  75. * pl_DevName    A short device "name" for device selection by name. 
  76. *
  77. * pl_type    0 for file-oriented device, 1 for interactive
  78. *        (the null driver uses -1 here)
  79. *
  80. * pl_init    Initialize device.  This routine may also prompt the user
  81. *        for certain device parameters or open a graphics file
  82. *        (see note).  Called only once to set things up.  Certain
  83. *        options such as familying and resolution (dots/mm) should
  84. *        be set up before calling this routine (note: some drivers
  85. *        ignore these).
  86. *
  87. * pl_line    Draws a line between two points. 
  88. *
  89. * pl_polyline    Draws a polyline (no broken segments).
  90. *
  91. * pl_eop    Finishes out current page (see note). 
  92. *
  93. * pl_bop    Set up for plotting on a new page. May also open a new
  94. *        a new graphics file (see note). 
  95. *
  96. * pl_tidy    Tidy up. May close graphics file (see note). 
  97. *
  98. * pl_state    Handle change in PLStream state
  99. *        (color, pen width, fill attribute, etc).
  100. *
  101. * pl_esc    Escape function for driver-specific commands.
  102. *
  103. *
  104. * Notes:
  105. *
  106. * Most devices allow multi-page plots to be stored in a single graphics
  107. * file, in which case the graphics file should be opened in the pl_init()
  108. * routine, closed in pl_tidy(), and page advances done by calling pl_eop
  109. * and pl_bop() in sequence. If multi-page plots need to be stored in
  110. * different files then pl_bop() should open the file and pl_eop() should
  111. * close it.  Do NOT open files in both pl_init() and pl_bop() or close
  112. * files in both pl_eop() and pl_tidy().
  113. \*----------------------------------------------------------------------*/
  114.  
  115. typedef struct {
  116.    char *pl_MenuStr;
  117.    char *pl_DevName;
  118.    int  pl_type;
  119.    void (*pl_init)    (PLStream *);
  120.    void (*pl_line)    (PLStream *, short, short, short, short);
  121.    void (*pl_polyline)    (PLStream *, short *, short *, PLINT);
  122.    void (*pl_eop)    (PLStream *);
  123.    void (*pl_bop)    (PLStream *);
  124.    void (*pl_tidy)    (PLStream *);
  125.    void (*pl_state)    (PLStream *, PLINT);
  126.    void (*pl_esc)    (PLStream *, PLINT, void *);
  127. } PLDispatchTable;
  128.  
  129. /*----------------------------------------------------------------------*\
  130. * Initialize dispatch table.
  131. *
  132. * Each device is selected by the appropriate define, passed in from the
  133. * makefile.  When installing plplot you may wish to exclude devices not 
  134. * present on your system in order to reduce screen clutter.
  135. *
  136. * If you hit a <CR> in response to the plinit() prompt, you get the FIRST
  137. * one active below, so arrange them accordingly for your system (i.e. all
  138. * the system-specific ones should go first, since they won't appear on
  139. * most systems.)
  140. \*----------------------------------------------------------------------*/
  141.  
  142. static PLDispatchTable dispatch_table[] = {
  143.  
  144.     /* Terminal types */
  145.  
  146. #ifdef PLD_next
  147.     {
  148.         "NeXT Display",
  149.         "next",
  150.     1,
  151.         plD_init_nx,
  152.         plD_line_nx,
  153.         plD_polyline_nx,
  154.         plD_eop_nx,
  155.         plD_bop_nx,
  156.         plD_tidy_nx,
  157.         plD_state_nx,
  158.         plD_esc_nx
  159.     },
  160. #endif
  161.  
  162. #ifdef PLD_amiga
  163.    {
  164.     "Amiga Window",
  165.     "amiwn",
  166.     1,
  167.     plD_init_amiwn,
  168.     plD_line_amiwn,
  169.     plD_polyline_amiwn,
  170.     plD_eop_amiwn,
  171.     plD_bop_amiwn,
  172.     plD_tidy_amiwn,
  173.     plD_state_amiwn,
  174.     plD_esc_amiwn
  175.    },
  176. #endif
  177.  
  178. #ifdef PLD_os2pm
  179.     {
  180.     "OS/2 PM Screen",
  181.     "os2",
  182.     1,
  183.     plD_init_os2,
  184.     plD_line_os2,
  185.     plD_polyline_os2,
  186.     plD_eop_os2,
  187.     plD_bop_os2,
  188.     plD_tidy_os2,
  189.     plD_state_os2,
  190.     plD_esc_os2
  191.     },
  192. #endif
  193.  
  194. #ifdef PLD_xwin
  195.     {
  196.     "X-Window (Xlib)",
  197.     "xwin",
  198.     1,
  199.     plD_init_xw,
  200.     plD_line_xw,
  201.     plD_polyline_xw,
  202.     plD_eop_xw,
  203.     plD_bop_xw,
  204.     plD_tidy_xw,
  205.     plD_state_xw,
  206.     plD_esc_xw
  207.     },
  208. #endif
  209.  
  210. #ifdef PLD_dp
  211.     {
  212.     "Tcl-DP/TK Window",
  213.     "dp",
  214.     1,
  215.     plD_init_dp,
  216.     plD_line_tk,
  217.     plD_polyline_tk,
  218.     plD_eop_tk,
  219.     plD_bop_tk,
  220.     plD_tidy_tk,
  221.     plD_state_tk,
  222.     plD_esc_tk
  223.     },
  224. #endif
  225.  
  226. #ifdef PLD_tk
  227.     {
  228.     "Tcl/TK Window",
  229.     "tk",
  230.     1,
  231.     plD_init_tk,
  232.     plD_line_tk,
  233.     plD_polyline_tk,
  234.     plD_eop_tk,
  235.     plD_bop_tk,
  236.     plD_tidy_tk,
  237.     plD_state_tk,
  238.     plD_esc_tk
  239.     },
  240. #endif
  241.  
  242. #ifdef PLD_linuxvga
  243.     {
  244.     "Linux console VGA Screen",
  245.     "vga",
  246.     1,
  247.     plD_init_vga,
  248.     plD_line_vga,
  249.     plD_polyline_vga,
  250.     plD_eop_vga,
  251.     plD_bop_vga,
  252.     plD_tidy_vga,
  253.     plD_state_vga,
  254.     plD_esc_vga
  255.     },
  256. #endif
  257.  
  258. #ifdef PLD_mgr
  259.     {
  260.     "MGR Window",
  261.     "mgr",
  262.     1,
  263.     plD_init_mgr,
  264.     plD_line_mgr,
  265.     plD_polyline_mgr,
  266.     plD_eop_mgr,
  267.     plD_bop_mgr,
  268.     plD_tidy_mgr,
  269.     plD_state_mgr,
  270.     plD_esc_mgr
  271.     },
  272. #endif
  273.  
  274. #ifdef PLD_win3
  275.     {
  276.     "Windows 3.x Driver",
  277.     "win3",
  278.     1,
  279.     plD_init_win3,
  280.     plD_line_win3,
  281.     plD_polyline_win3,
  282.     plD_eop_win3,
  283.     plD_bop_win3,
  284.     plD_tidy_win3,
  285.     plD_state_win3,
  286.     plD_esc_win3
  287.     },
  288. #endif
  289.  
  290. #if defined (_MSC_VER) && defined (VGA)         /* graphics for msc */
  291.     {
  292.     "DOS VGA Screen (msc)",
  293.     "vga",
  294.     1,
  295.     plD_init_vga,
  296.     plD_line_vga,
  297.     plD_polyline_vga,
  298.     plD_eop_vga,
  299.     plD_bop_vga,
  300.     plD_tidy_vga,
  301.     plD_state_vga,
  302.     plD_esc_vga
  303.     },
  304. #endif
  305.  
  306. #ifdef PLD_bgi
  307.     {
  308.     "VGA Screen (BGI)",
  309.     "vga",
  310.     1,
  311.     plD_init_vga,
  312.     plD_line_vga,
  313.     plD_polyline_vga,
  314.     plD_eop_vga,
  315.     plD_bop_vga,
  316.     plD_tidy_vga,
  317.     plD_state_vga,
  318.     plD_esc_vga
  319.     },
  320. #endif
  321.  
  322. #ifdef PLD_gnusvga
  323.     {
  324.     "SVGA Screen (djgpp)",
  325.     "vga",
  326.     1,
  327.     plD_init_vga,
  328.     plD_line_vga,
  329.     plD_polyline_vga,
  330.     plD_eop_vga,
  331.     plD_bop_vga,
  332.     plD_tidy_vga,
  333.     plD_state_vga,
  334.     plD_esc_vga
  335.     },
  336. #endif
  337.  
  338. #ifdef PLD_emxvga               /* graphics for emx+gcc */
  339.     {
  340.     "VGA Screen (emx)",
  341.     "vga",
  342.     1,
  343.     plD_init_vga,
  344.     plD_line_vga,
  345.     plD_polyline_vga,
  346.     plD_eop_vga,
  347.     plD_bop_vga,
  348.     plD_tidy_vga,
  349.     plD_state_vga,
  350.     plD_esc_vga
  351.     },
  352. #endif
  353.  
  354. #ifdef PLD_xterm
  355.     {
  356.     "Xterm Window",
  357.     "xterm",
  358.     1,
  359.     plD_init_xterm,
  360.     plD_line_tek,
  361.     plD_polyline_tek,
  362.     plD_eop_tek,
  363.     plD_bop_tek,
  364.     plD_tidy_tek,
  365.     plD_state_tek,
  366.     plD_esc_tek
  367.     },
  368. #endif
  369.  
  370. #ifdef PLD_tek4010
  371.     {
  372.     "Tektronix Terminal (4010)",
  373.     "tekt",
  374.     1,
  375.     plD_init_tekt,
  376.     plD_line_tek,
  377.     plD_polyline_tek,
  378.     plD_eop_tek,
  379.     plD_bop_tek,
  380.     plD_tidy_tek,
  381.     plD_state_tek,
  382.     plD_esc_tek
  383.     },
  384. #endif
  385.  
  386. #ifdef PLD_tek4107
  387.     {
  388.     "Tektronix Terminal (4105/4107)",
  389.     "tek4107t",
  390.     1,
  391.     plD_init_tek4107t,
  392.     plD_line_tek,
  393.     plD_polyline_tek,
  394.     plD_eop_tek,
  395.     plD_bop_tek,
  396.     plD_tidy_tek,
  397.     plD_state_tek,
  398.     plD_esc_tek
  399.     },
  400. #endif
  401.  
  402. #ifdef PLD_mskermit
  403.     {
  404.     "MS-Kermit emulator",
  405.     "mskermit",
  406.     1,
  407.     plD_init_mskermit,
  408.     plD_line_tek,
  409.     plD_polyline_tek,
  410.     plD_eop_tek,
  411.     plD_bop_tek,
  412.     plD_tidy_tek,
  413.     plD_state_tek,
  414.     plD_esc_tek
  415.     },
  416. #endif
  417.  
  418. #ifdef PLD_versaterm
  419.     {
  420.     "Versaterm vt100/tek emulator",
  421.     "versaterm",
  422.     1,
  423.     plD_init_versaterm,
  424.     plD_line_tek,
  425.     plD_polyline_tek,
  426.     plD_eop_tek,
  427.     plD_bop_tek,
  428.     plD_tidy_tek,
  429.     plD_state_tek,
  430.     plD_esc_tek
  431.     },
  432. #endif
  433.  
  434. #ifdef PLD_vlt
  435.     {
  436.     "VLT vt100/tek emulator",
  437.     "vlt",
  438.     1,
  439.     plD_init_vlt,
  440.     plD_line_tek,
  441.     plD_polyline_tek,
  442.     plD_eop_tek,
  443.     plD_bop_tek,
  444.     plD_tidy_tek,
  445.     plD_state_tek,
  446.     plD_esc_tek
  447.     },
  448. #endif
  449.  
  450. #ifdef PLD_conex
  451.     {
  452.     "Conex vt320/tek emulator",
  453.     "conex",
  454.     1,
  455.     plD_init_conex,
  456.     plD_line_tek,
  457.     plD_polyline_tek,
  458.     plD_eop_tek,
  459.     plD_bop_tek,
  460.     plD_tidy_tek,
  461.     plD_state_tek,
  462.     plD_esc_tek
  463.     },
  464. #endif
  465.  
  466. #ifdef PLD_dg300
  467.     {
  468.     "DG300 Terminal",
  469.     "dg300",
  470.     1,
  471.     plD_init_dg,
  472.     plD_line_dg,
  473.     plD_polyline_dg,
  474.     plD_eop_dg,
  475.     plD_bop_dg,
  476.     plD_tidy_dg,
  477.     plD_state_dg,
  478.     plD_esc_dg
  479.     },
  480. #endif
  481.  
  482.     /* File types */
  483.  
  484. #ifdef PLD_plmeta
  485.     {
  486.     "PLPLOT Native Meta-File",
  487.     "plmeta",
  488.     0,
  489.     plD_init_plm,
  490.     plD_line_plm,
  491.     plD_polyline_plm,
  492.     plD_eop_plm,
  493.     plD_bop_plm,
  494.     plD_tidy_plm,
  495.     plD_state_plm,
  496.     plD_esc_plm
  497.     },
  498. #endif
  499.  
  500. #ifdef PLD_tek4010
  501.     {
  502.     "Tektronix File (4010)",
  503.     "tekf",
  504.     0,
  505.     plD_init_tekf,
  506.     plD_line_tek,
  507.     plD_polyline_tek,
  508.     plD_eop_tek,
  509.     plD_bop_tek,
  510.     plD_tidy_tek,
  511.     plD_state_tek,
  512.     plD_esc_tek
  513.     },
  514. #endif
  515.  
  516. #ifdef PLD_tek4107
  517.     {
  518.     "Tektronix File (4105/4107)",
  519.     "tek4107f",
  520.     0,
  521.     plD_init_tek4107f,
  522.     plD_line_tek,
  523.     plD_polyline_tek,
  524.     plD_eop_tek,
  525.     plD_bop_tek,
  526.     plD_tidy_tek,
  527.     plD_state_tek,
  528.     plD_esc_tek
  529.     },
  530. #endif
  531.  
  532. #ifdef PLD_ps
  533.     {
  534.     "PostScript File (monochrome)",
  535.     "ps",
  536.     0,
  537.     plD_init_psm,
  538.     plD_line_ps,
  539.     plD_polyline_ps,
  540.     plD_eop_ps,
  541.     plD_bop_ps,
  542.     plD_tidy_ps,
  543.     plD_state_ps,
  544.     plD_esc_ps
  545.     },
  546.     {
  547.     "PostScript File (color)",
  548.     "psc",
  549.     0,
  550.     plD_init_psc,
  551.     plD_line_ps,
  552.     plD_polyline_ps,
  553.     plD_eop_ps,
  554.     plD_bop_ps,
  555.     plD_tidy_ps,
  556.     plD_state_ps,
  557.     plD_esc_ps
  558.     },
  559. #endif
  560.  
  561. #ifdef PLD_xfig
  562.     {
  563.     "Xfig file",
  564.     "xfig",
  565.     0,
  566.     plD_init_xfig,
  567.     plD_line_xfig,
  568.     plD_polyline_xfig,
  569.     plD_eop_xfig,
  570.     plD_bop_xfig,
  571.     plD_tidy_xfig,
  572.     plD_state_xfig,
  573.     plD_esc_xfig
  574.     },
  575. #endif
  576.  
  577. #ifdef PLD_ljii
  578.     {
  579.     "LaserJet IIp/deskjet compressed graphics",
  580.     "ljiip",
  581.     0,
  582.     plD_init_ljiip,
  583.     plD_line_ljiip,
  584.     plD_polyline_ljiip,
  585.     plD_eop_ljiip,
  586.     plD_bop_ljiip,
  587.     plD_tidy_ljiip,
  588.     plD_state_ljiip,
  589.     plD_esc_ljiip
  590.     },
  591.     {
  592.     "LaserJet II Bitmap File (150 dpi)",
  593.     "ljii",
  594.     0,
  595.     plD_init_ljii,
  596.     plD_line_ljii,
  597.     plD_polyline_ljii,
  598.     plD_eop_ljii,
  599.     plD_bop_ljii,
  600.     plD_tidy_ljii,
  601.     plD_state_ljii,
  602.     plD_esc_ljii
  603.     },
  604. #endif
  605.  
  606. #ifdef PLD_amiga
  607.     {
  608.     "Amiga Printer (prefs settings)",
  609.     "amipr",
  610.     0,
  611.     plD_init_amipr,
  612.     plD_line_amipr,
  613.     plD_polyline_amipr,
  614.     plD_eop_amipr,
  615.     plD_bop_amipr,
  616.     plD_tidy_amipr,
  617.     plD_state_amipr,
  618.     plD_esc_amipr
  619.     },
  620. #endif
  621.  
  622. #ifdef PLD_iff    /* probably only of interest on the Amiga */
  623.    {
  624.     "IFF Graphics File",
  625.     "iff",
  626.     0,
  627.     plD_init_iff,
  628.     plD_line_iff,
  629.     plD_polyline_iff,
  630.     plD_eop_iff,
  631.     plD_bop_iff,
  632.     plD_tidy_iff,
  633.     plD_state_iff,
  634.     plD_esc_iff
  635.    },
  636. #endif
  637.  
  638. #ifdef PLD_aegis    /* probably only of interest on the Amiga */
  639.    {
  640.     "Aegis Draw File",
  641.     "aegis",
  642.     0,
  643.     plD_init_aegis,
  644.     plD_line_aegis,
  645.     plD_polyline_aegis,
  646.     plD_eop_aegis,
  647.     plD_bop_aegis,
  648.     plD_tidy_aegis,
  649.     plD_state_aegis,
  650.     plD_esc_aegis
  651.    },
  652. #endif
  653.  
  654. #ifdef PLD_hp7470
  655.     {
  656.     "HP 7470 Plotter File (HPGL Cartridge, Small Plotter)",
  657.     "hp7470",
  658.     0,
  659.     plD_init_hp7470,
  660.     plD_line_hpgl,
  661.     plD_polyline_hpgl,
  662.     plD_eop_hpgl,
  663.     plD_bop_hpgl,
  664.     plD_tidy_hpgl,
  665.     plD_state_hpgl,
  666.     plD_esc_hpgl
  667.     },
  668. #endif
  669.  
  670. #ifdef PLD_hp7580
  671.     {
  672.     "HP 7580 Plotter File (Large Plotter)",
  673.     "hp7580",
  674.     0,
  675.     plD_init_hp7580,
  676.     plD_line_hpgl,
  677.     plD_polyline_hpgl,
  678.     plD_eop_hpgl,
  679.     plD_bop_hpgl,
  680.     plD_tidy_hpgl,
  681.     plD_state_hpgl,
  682.     plD_esc_hpgl
  683.     },
  684. #endif
  685.  
  686. #ifdef PLD_lj_hpgl
  687.     {
  688.     "HP Laserjet III, HPGL emulation mode",
  689.     "lj_hpgl",
  690.     0,
  691.     plD_init_lj_hpgl,
  692.     plD_line_hpgl,
  693.     plD_polyline_hpgl,
  694.     plD_eop_hpgl,
  695.     plD_bop_hpgl,
  696.     plD_tidy_hpgl,
  697.     plD_state_hpgl,
  698.     plD_esc_hpgl
  699.     },
  700. #endif
  701.  
  702. #ifdef PLD_imp
  703.     {
  704.     "Impress File",
  705.     "imp",
  706.     0,
  707.     plD_init_imp,
  708.     plD_line_imp,
  709.     plD_polyline_imp,
  710.     plD_eop_imp,
  711.     plD_bop_imp,
  712.     plD_tidy_imp,
  713.     plD_state_imp,
  714.     plD_esc_imp
  715.     },
  716. #endif
  717.  
  718. #ifdef PLD_null
  719.     {
  720.     "Null device",
  721.     "null",
  722.     -1,
  723.     plD_init_null,
  724.     plD_line_null,
  725.     plD_polyline_null,
  726.     plD_eop_null,
  727.     plD_bop_null,
  728.     plD_tidy_null,
  729.     plD_state_null,
  730.     plD_esc_null
  731.     }
  732. #endif
  733. };
  734.  
  735. static PLINT npldrivers = (sizeof(dispatch_table)/sizeof(PLDispatchTable));
  736.  
  737. #endif    /* __PLCORE_H__ */
  738.